/* Polynom.h header file
   ---------------------
   specifies class properties and methods
 */

#ifndef _POLYNOM_H
#define _POLYNOM_H

#include <iostream>
#include "Monom.h"

using namespace std;

// Polynom's linked list class
class mNode{
public:
    mNode *next;
    Monom m;
};

class Polynom {
    friend const Polynom operator+(const Monom &m, const Polynom &p);	// Arithmetic addition: Monom + Polynom
    friend const Polynom operator-(const Monom &m, const Polynom &p);	// Arithmetic subtraction: Monom - Polynom
    friend ostream& operator <<(ostream &out, const Polynom &p);		// Operator for cout << Polynom
public:

    // Constructors & Destructors
    Polynom();															// Default empty constructor
    Polynom(const Polynom &p);											// Copy Constructor (Polynom)
    Polynom(const Monom &m);											// Copy Constructor (Monom)
    ~Polynom();															// Destructor

    // Operators overloading
    Polynom& operator=(const Polynom &p);								// assignment operator '='
    const Polynom operator+(const Polynom &p) const;					// arithmetic addition: Polynom + Polynom
    const Polynom operator+(const Monom &m) const;						// arithmetic addition: Polynom + Monom
    const Polynom operator-(const Polynom &p) const;					// arithmetic subtraction: Polynom - Polynom
    const Polynom operator-(const Monom &m) const;						// arithmetic subtraction: Polynom - Monom

    // Misc methods
	const int getOrder() const;                                         // Returns the order of the Polynom
    const Polynom& derive();											// Derives current object and returns ref to *this

private:
	void allMinus();													// performs m.C *= -1 for all Monoms in Polynom
	Polynom& DoOp(Polynom &p2, char OpType);						    // Arithmetic '+' and '-' method
    void InsertSortedNode(const mNode *pn);                             // Addition: Polynom + mNode

    mNode *head;														// Pointer to head of linked-list

};

#endif